
#include <BFont>
#include <BPainter>
#include <BStyle>
#include <BMouseEvent>

#include <BRadioBox>
#include "member_BButton.h"

using namespace BWE;

BRadioBox::BRadioBox(BWidget* parent) : BButton(parent)
{
	_ptr = 0;
	this->setAlign(Align_LeftCenter);
	this->setGraph(Graph_Space);
	this->setCheckable(true);
}
BRadioBox::BRadioBox(const BString& text, BWidget* parent) : BButton(text, parent)
{
	_ptr = 0;
	this->setAlign(Align_LeftCenter);
	this->setGraph(Graph_Space);
	this->setCheckable(true);
}
BRadioBox::~BRadioBox()
{

}

void BRadioBox::freshEvent(const BEvent& event)
{
	BButton::freshEvent(event);
}

void BRadioBox::paintEvent(const BEvent& event)
{
	BButton::paintEvent(event);

	if (!button_member(this)->icon && button_member(this)->graph == Graph_Space)
	{
		BPainter painter(this);
		State state = button_member(this)->state;
		BRect& imageRect = button_member(this)->alignment.ia_imageRect;

		if (state == State_Disable)
			painter.setColor(Color_Arrow_Disable);
		else if (state == State_Hovered)
			painter.setColor(Color_Arrow_Hovered);
		else
			painter.setColor(Color_Arrow);

		int radius = imageRect.height() / 2;
		painter.setLineSmooth(true);
		painter.setLineWidth(2);
		painter.drawCircle(imageRect.center(), int(radius));
		if (button_member(this)->checked)
		{
			int innerRadius = radius / 2;
			painter.fillCircle(imageRect.center(), innerRadius);
			painter.setColor(painter.color() * 0.5);
			painter.drawCircle(imageRect.center(), innerRadius + 1);
		}
	}
}
